package com.aliang.shopping.util;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.util.ArrayList;
import java.util.List;

public class DataUtil {

    public static Integer sum = 0;

    /**
     * 获取当天开始时间
     */
    public static LocalDateTime getToDayStartTime() {
        LocalDate now = LocalDate.now();
        return now.atStartOfDay();
    }

    /**
     * 获取当天结束时间
     */
    public static LocalDateTime getToDayEndTime() {
        LocalDate now = LocalDate.now();
        return LocalDateTime.of(now, LocalTime.MAX);
    }

    /**
     * 获取当天开始时间
     */
    public static List<LocalDateTime> getToDayStartAndEndTime() {
        LocalDate now = LocalDate.now();
        List<LocalDateTime> list = new ArrayList<>(2);
        list.add(now.atStartOfDay());// 获取当天开始时间
        list.add(LocalDateTime.of(now, LocalTime.MAX)); // 获取当天结束时间
        return list;
    }


    /**
     * 获取昨天开始时间
     */
    public static LocalDateTime getYesterdayStartTime() {
        LocalDate yesterday = LocalDate.now().minusDays(1);
        return yesterday.atStartOfDay();
    }

    /**
     * 获取昨天结束时间
     */
    public static LocalDateTime getYesterdayEndTime() {
        LocalDate yesterday = LocalDate.now().minusDays(1);
        return LocalDateTime.of(yesterday, LocalTime.MAX);
    }

    /**
     * 获取昨天开始和结束时间
     */
    public static List<LocalDateTime> getYesterdayStartAndEndTime() {
        LocalDate yesterday = LocalDate.now().minusDays(1);
        List<LocalDateTime> list = new ArrayList<>(2);
        list.add(yesterday.atStartOfDay());// 获取昨天开始时间
        list.add(LocalDateTime.of(yesterday, LocalTime.MAX)); // 获取昨天结束时间
        return list;
    }

    /**
     * 获取近7天的开始时间
     */
    public static LocalDateTime getWeekStartTime() {
        LocalDate week = LocalDate.now().minusDays(7);

        return week.atStartOfDay();
    }
    /**
     * 获取近七天开始和结束时间
     */
    public static List<LocalDateTime> getWeekStartAndEndTime() {
        LocalDate now = LocalDate.now();
        LocalDate week = LocalDate.now().minusDays(7);
        List<LocalDateTime> list = new ArrayList<>(2);
        list.add(week.atStartOfDay());// 获取近七天开始时间
        list.add(LocalDateTime.of(now, LocalTime.MAX)); // 获取今天结束时间
        return list;
    }
}
